#include "bestsoft.h"
elf_t kernel_elf;
spinlock_t lock = SPINLOCK_UNLOCKED;
Char original[100];
int com=-1;
int fn(void *arg)
{
for(;;) {
int i;
spinlock_lock(&lock);
for(i = 0; i < 80; i++)
printk("a");
spinlock_unlock(&lock);
}
return 6;
}
int main(multiboot_t *mboot_ptr)
{
clear();
write("Bestsoft Example OS\n>");
init_gdt();
init_idt();
init_timer(20);
init_pmm(mboot_ptr->mem_upper);
init_vmm();
init_heap();
// Find all the usable areas of memory and inform the physical memory manager about them.
uint32_t i = mboot_ptr->mmap_addr;
while (i < mboot_ptr->mmap_addr + mboot_ptr->mmap_length)
{
mmap_entry_t *me = (mmap_entry_t*) i;
// Does this entry specify usable RAM?
if (me->type == 1)
{
uint32_t j;
// For every page in this entry, add to the free page stack.
for (j = me->base_addr_low; j < me->base_addr_low+me->length_low; j += 0x10000)
{
pmm_free_page (j);
}
}
// The multiboot specification is strange in this respect - the size member does not include "size" itself in its calculations,
// so we must add sizeof (uint32_t).
i += me->size + sizeof (uint32_t);
}
kernel_elf = elf_from_multiboot (mboot_ptr);
asm volatile ("sti");
init_scheduler (init_threading ());
init_keyboard_driver();
for(;;)
{
Char c = keyboard_getChar();
if (c){
monitor_put(c);
com=com+1;
original[com]=c;
}
if (c=='\n'){
if(strcmp(original,"hello\n")==0){
write("Hi User\n");
}else{
if(strcmp(original,"clean\n")==0){
clear();
write("Bestsoft OS Example\n>");
}else{
write(original);
write("not found!\n>");
}
}
com=-1;
}
}
for (;;);
return 0xdeadbeef;
}